﻿using System;
using System.Runtime.InteropServices;
using Autodesk.Revit.UI;
using YJKCodeBase.WinForm;
using RevitInteractiveUtility.ExternalEventManager;

namespace FetchDataCompare
{
	internal class FetchManager
	{
		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		public ExternalCommandData Revit { get; set; }

		public DocumentManger SrcDocument { get; set; }

		private ReportDataListForm m_Form { get; set; }

		public DocumentManger DesDocument { get; set; }

		public FetchManager(ExternalCommandData revit, DocumentManger srcDoc, DocumentManger desDoc, WindowHandle revitHandle)
		{
			FetchManager._hWndRevit = revitHandle;
			this.Revit = revit;
			this.SrcDocument = srcDoc;
			this.DesDocument = desDoc;
		}

		public FetchManager(ExternalCommandData revit, WindowHandle revitHandle)
		{
			FetchManager._hWndRevit = revitHandle;
			this.Revit = revit;
		}

		public void DoCompare()
		{
			ExternalEventManagerSingleton.GetEventManger(false).ReSetRequest();
			FetchDataCompareForm fetchDataCompareForm = new FetchDataCompareForm(this.Revit, FetchManager._hWndRevit);
			fetchDataCompareForm.ShowDialog(FetchManager._hWndRevit);
			int wMsg = 7;
			FetchManager.SendMessage(FetchManager._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
		}

		private static WindowHandle _hWndRevit;
	}
}
